Skip to content

Port Scheduler library to Arduino Zero. #3958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2015

Conversation

PeterVH
Copy link

@PeterVH PeterVH commented Oct 11, 2015

The library from the Due does not work as is on the Zero because it loads and stores the processor state using ldmia/stmia. On cortex m0, these instructions only work with the 'low' registers (r0-r7).

I made an implementation that loads the registers in the low registers first, and then moves them into the high regs.
Tested with MultipleBlink sketch.
Some feedback review on the code is desirable.
See forum

@@ -64,11 +83,39 @@ static void __attribute__((naked)) __attribute__((noinline)) coopTaskStart(void)
static void __attribute__((naked)) __attribute__((noinline)) coopDoYield(CoopTask* curTask) {
asm (
"mov r12, sp;"
"stmia r0, {r4-r12, lr};"
/* store low registers */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall this be put inside ifdef too, so we can use the more efficient store instruction when available (without copying the high registers into the low registers)?

@cmaglie cmaglie added Architecture: SAM Applies only to the SAM microcontrollers (Due) and removed Architecture: SAM Applies only to the SAM microcontrollers (Due) labels Oct 12, 2015
@cmaglie cmaglie self-assigned this Oct 12, 2015
@cmaglie cmaglie added Library: Scheduler The Scheduler Arduino library feature request A request to make an enhancement (not a bug fix) labels Oct 12, 2015
@PeterVH
Copy link
Author

PeterVH commented Oct 13, 2015

Yes indeed, that chunk of m0 specific code escaped my attention.
I fixed both issues you brought up and squashed everything in one commit again.

B.t.w. I had big trouble testing this on my Due. Is there something seriously wrong with sam package 1.6.4? I could upload sketches to the Due (prog port) but could not run any simple led blinking program. Thought for a moment my Due was toasted. I reverted to 1.6.3 and everything was back ok.

Anyway test passed on Due too.

@cmaglie cmaglie merged commit 739c656 into arduino:master Oct 28, 2015
@cmaglie cmaglie added this to the Release 1.6.6 milestone Oct 28, 2015
@q2dg
Copy link

q2dg commented Jan 1, 2016

Should https://www.arduino.cc/en/Reference/Libraries list be updated to reflect Scheduler is "Due and Zero only", then?

If it is, Zero board should be referenced too in first sentence of https://www.arduino.cc/en/Reference/Scheduler ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request to make an enhancement (not a bug fix) Library: Scheduler The Scheduler Arduino library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants